﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Emessenger
{
    /// <summary>
    /// Interaction logic for ChatRoom.xaml
    /// </summary>
    public partial class ChatRoom : Window
    {
        private WODXMPPCOMLib.wodXMPPComClass wodXMPP1;
        public ChatRoom(WODXMPPCOMLib.wodXMPPComClass wodXMPP)
        {
            InitializeComponent();
            wodXMPP1 = wodXMPP;
            wodXMPP1.ServiceStatusChange += new WODXMPPCOMLib._IwodXMPPComEvents_ServiceStatusChangeEventHandler(wodXMPP1_ServiceStatusChange);
            wodXMPP1.ChatRoomData += new WODXMPPCOMLib._IwodXMPPComEvents_ChatRoomDataEventHandler(wodXMPP1_ChatRoomData);
            wodXMPP1.Services.Discover(true);

            // j ai pas trouver commment on l'utilise :(
            //wodXMPP1.ChatRoomListDone += new WODXMPPCOMLib._IwodXMPPComEvents_ChatRoomListDoneEventHandler(wodXMPP1_ChatRoomListDone);
        }










        void wodXMPP1_ChatRoomData(WODXMPPCOMLib.XMPPChatRoom Room)
        {
            Room.SaveSettings();
        }

       
        
        void wodXMPP1_ServiceStatusChange(WODXMPPCOMLib.XMPPService Service)
        {
            bool SupportsConference = false, Found = false;

            for (int i = 0; i < Service.Identity.Count; i++)
            {
                if (Service.Identity[i].Category == WODXMPPCOMLib.IdentityCategoryEnum.CatConference)
                    SupportsConference = true;
            }

            if (SupportsConference)
            {
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    if (listBox1.Items[i].ToString() == Service.JID)
                        Found = true;
                }

                if (!Found)
                    listBox1.Items.Add(Service.JID);
                    //listBox1.Items.Add(wodXMPP1.ChatRooms[0].Name);
            }
        }

        

        



    }
}
